import { configureStore } from "@reduxjs/toolkit";
import undoable, { excludeAction, StateWithHistory } from "redux-undo";
import userReducer, { UserStateType } from "./userReducer";
import pageInfoReducer, { PageInfoType } from "./pageInfoReducer";
import componentsSlice, { ComponentStateType } from "./componentsReducer";
export type StateType = {
  user: UserStateType;
  components: StateWithHistory<ComponentStateType>;
  pageInfo: PageInfoType;
};
export default configureStore({
  reducer: {
    //用户信息
    user: userReducer,
    //组件列表
    // components: componentsSlice,
    components: undoable(componentsSlice, {
      limit: 20, //限制记录重做20步
      //过滤出需要忽略的操作,不进行记录
      filter: excludeAction([
        //bug,开始获取数据时canvas数据未被获取时状态也被记录
        // "components/resetComponents",
        "components/changeSelectId",
        "components/selectPreviousComponent",
        "components/selectNextComponent",
      ]),
    }),
    //问卷信息
    pageInfo: pageInfoReducer,
  },
});
